#include <stdio.h>

unsigned long ByteSwap(unsigned long val)
{
	int ch;

	_asm volatile (
	"eor r3, %1, %1, ror #16\n\t"
		"bic r3, r3, #0x00ff0000\n\t"
		"mov %0, %1, ror #8\n\t"
		"eor %0, %0, r3, lsr #8"
		: "=r" (val)
		: "0" (val)
		: "r3"
	);
}

int main(void)
{
	unsigned long result, test_a = 0x1234;
	result = ByteSwap(test_a);
	printf("Result:%d\r\n", result);

	system("pause");
	return 0;
}